<div ng-if="pagedata.shownewpicker" class="popup">
<div class="popup-body">
<div class="popup-bottom">
<style>
.option-picker .fui-navbar .cartbtn {
    padding-right:0.3rem;background:#fff;opacity:1
}

.option-picker .fui-navbar .buybtn, .option-picker .fui-navbar .confirmbtn {
    padding-left:0.3rem;background:#fff
}
.fee-tag-nav, .fee-tagup-nav, .fee-disabled-nav {border-radius:1rem;height:2rem;line-height:2rem;color:#fff;width:100%;font-weight:400;font-size:0.7rem;margin:0.2rem 0;padding:0 0.2rem}
.fee-tagup {background:{{main.syscolor || 'red'}};color:#fff;width:auto;font-weight:400;font-size:0.55rem}
.fee-tag-nav {background:{{main.syscolor || 'red'}}; opacity: 0.58;}
.fee-tagup-nav {background:{{main.syscolor || 'red'}};}
.fee-disabled-nav {background:#bbb;color:#fff;}	
.modal-swiper-y {
    height: 12rem;
}
</style>
<div class="option-picker">
	<div class="option-picker-inner">
		<div class="option-picker-cell goodinfo">
			<div class="closebtn" ng-click="pagedata.shownewpicker=false"><i class="closed icon icon-cuowu"></i></div>
			<div class="img"><img class='thumb' ng-src="{{tomedia(pagedata.goods.image) || '../core/resource/images/nopic.jpg'}}" /></div>
			<div class="info info-price text-danger">
					<span>
						￥
						<span class='price' style="font-weight:600">
						{{pagedata.goods.showprice || '0.00'}}
						</span>
						<span ng-if="pagedata.goods.showoldprice" class='delete'>
						原价：{{pagedata.goods.showoldprice || '0.00'}}
						</span>
					</span>
			</div>
			<div ng-if="pagedata.goods.isshowsales=='1'" class="info info-total">
					<span>库存 <span class='total'>{{pagedata.options.stock || 0}}</span> {{pagedata.goods.unit || '件'}}</span>
			</div>
			<div class="info info-titles">请选择规格</div>
		</div>
		<div class="option-picker-options modal-swiper-y">
			<div ng-repeat="(k,spec) in pagedata.goods.specs_list" class="option-picker-cell option spec">
			<div class="title">{{spec.title}}</div>
			<div class="select">
				 <a ng-repeat="item in spec.items" href="javascript:;" ng-click="pagedata.goods.specid[k]=item.id;pagedata.get_optionsid();" ng-class="{'btn btn-default btn-sm nav spec-item':1,'btn-select':pagedata.goods.specid[k]==item.id}"> {{item.title}} </a>
			</div>
			</div>
			<div ng-if="!pagedata.goods.specs_list || pagedata.goods.specs_list.length==0" class="option-picker-cell option spec">
			<div class="title">规格</div>
			<div class="select">
				 <a class="btn btn-default btn-sm nav spec-item btn-select"> 默认 </a>
			</div>
			</div>
			<div class="fui-cell-group noborder" style="margin-top:0">
				<div class="fui-cell noborder">
				<div class="fui-cell-label">数量</div>
				<div class="fui-cell-info"></div>
				<div class="fui-cell-mask noremark">
					 <div class="fui-number">
						<div class="minus" ng-click="pagedata.postnum_minus();">-</div>
						<input class="num" type="text" ng-model="pagedata.pickpost.num"/>
						<div class="plus" ng-click="pagedata.postnum_plus();">+</div>
					</div>
				</div>
				<div style="line-height:1.5rem;color:#999;font-size:0.6rem;padding-left:0.2rem">{{pagedata.goods.unit || '件'}}</div>
				</div>
			</div>
		</div>
		<div class="fui-navbar" style="-webkit-box-shadow:0 0 0 rgba(0,0,0,0.1);">
			<a ng-if="pagedata.goods.canbuynum>0" aria-hidden="true" data-dismiss="modal" href="javascript:;" ng-click="pagedata.pickaddtocart();" class="nav-item btn cartbtn">
				<div class="fee-tag-nav">
					加入购物车
				</div>
			</a>
			<a ng-if="pagedata.goods.canbuynum>0" aria-hidden="true" data-dismiss="modal" href="javascript:;" ng-click="pagedata.gotoitem(pagedata.goods);" class="nav-item btn cartbtn">
				<div class="fee-tagup-nav">
					立即购买
				</div>
			</a>
			<a ng-if="pagedata.goods.options.stock==0" class="nav-item btn cartbtn">
				<div class="fee-disabled-nav">
					已售馨
				</div>
			</a>
		</div>
    </div>	
</div>
</div>
</div>
</div>
<script>
scope.pagedata.pickpost={'num':1}
scope.pagedata.postnum_minus=function(){
	if(scope.pagedata.pickpost.num==1){
		scope.message('不能再减了！','error');
		return false;
	}
	scope.pagedata.pickpost.num--
}
scope.pagedata.postnum_plus=function(){
	if(scope.pagedata.pickpost.num>=scope.pagedata.goods.canbuynum){
			scope.message('不能再添加了，已超过库存！','error');
			return false;
	}
	scope.pagedata.pickpost.num++
}
scope.pagedata.gotopicker=function(item){
	scope.pagedata.goods=item;
	scope.pagedata.goods.canbuynum=scope.pagedata.goods.total;
	scope.pagedata.pickpost.goodsid=scope.pagedata.goods.id;
	if(item.options && item.options.id){
		scope.pagedata.pickpost.optionid=item.options.id
		scope.pagedata.goods.showprice=item.options.price
		scope.pagedata.goods.showoldprice=item.options.oldprice
		scope.get('jy_weishop/get_data/specs_list/goodsid='+item.id+'&specs='+item.options.specs,function(res){
			scope.pagedata.goods.specs_list=res.list;
			scope.pagedata.goods.specid=res.specid;
			scope.pagedata.goods.canbuynum=scope.pagedata.goods.options.stock;
			scope.$evalAsync();
			scope.pagedata.shownewpicker=true;
		});
	}else{
		scope.pagedata.goods.showprice=item.price
		scope.pagedata.goods.showoldprice=item.oldprice
		scope.$evalAsync();
		scope.pagedata.shownewpicker=true;
	}
}
scope.pagedata.gotoitem=function(item){
	if(item.pluginname=='jy_taobaoke'){
		$('#showtaobaoke').modal();
		scope.pagedata.selectgoods=item;
		scope.pagedata.copyinfo='【'+item.title+'】'+item.active.url+' 点击链接，再选择浏览器打开；或复制这段描述'+item.active.code+'后到《手机淘宝》';
		scope.$evalAsync();
	}else{
		scope.pagedata.shownewpicker=false;
		scope.access_json(item.active.url || 'jy_weishop/goods.detail//id='+item.id);
	}
}
//选择
scope.pagedata.get_optionsid=function(){
	var specid = scope.pagedata.goods.specid;
	specid = specid.join('_');
	scope.post_json('jy_weishop/goods.detail/get_optionsid/',{'goodsid':scope.pagedata.goods.id,'specid':specid},function(res){
			scope.pagedata.pickpost.optionid=res.options.id;
			scope.pagedata.goods.options=res.options;
			scope.pagedata.goods.showprice=res.options.price
			scope.pagedata.goods.showoldprice=res.options.oldprice
			scope.pagedata.goods.canbuynum=scope.pagedata.goods.options.stock;
			scope.pagedata.goods.selespename=res.selespename;
			scope.$evalAsync();
	});
}
scope.pagedata.pickaddtocart=function(){
	scope.post_json('jy_weishop/member.cart/addtocart/',scope.pagedata.pickpost,function(res){
		if(scope.main.menus && scope.main.menus.length>0){
			for(var i=0;i<scope.main.menus.length;i++){
				if(scope.main.menus[i].action=='jy_weishop/member.cart/'){
					scope.main.menus[i].nums += scope.pagedata.pickpost.num
				}
			}
		}
		scope.message('加入成功！','error');
		scope.pagedata.shownewpicker=false;
	});
}
</script>